package com.njzxw.fs.commonutil.bean;

import com.njzxw.fs.commonutil.util.StringHelper;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;

import java.util.Map;

/**
 * 基本用户信息  该参数类只有在进入control时才会进行赋值操作，其他不进行赋值操作
 */
@Setter
@Getter
@ToString
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS, value = WebApplicationContext.SCOPE_REQUEST)
@Component
public class BaseUserBean {

    public String oper_id;

    public String token;

    public Map<String,Object> map;

    /**
     * 获取map中存储的值
     * @param key
     * @param valueType
     * @param <T>
     * @return
     */
    public <T>T getValue(String key,Class<T> valueType){
        if(map == null){
            return null;
        }
        Object obj = map.get(key);
        System.out.println("======"+obj);
        return obj == null?null:(T)obj;
    }

}
